package com.winbomb.kingcard.base.anim.impl;

import com.winbomb.kingcard.Assets;
import com.winbomb.kingcard.IGameLogic;
import com.winbomb.kingcard.Pos;
import com.winbomb.kingcard.base.BattleState;
import com.winbomb.kingcard.base.GameLogic;
import com.winbomb.kingcard.base.anim.IPlayable;
import com.winbomb.kingcard.base.anim.SimpleAnimation;
import com.winbomb.kingcard.framework.Graphics;

public class BattleStartAnim implements IPlayable {

	private SimpleAnimation anim;
	private Graphics g;
	private IGameLogic game;

	public BattleStartAnim(IGameLogic game) {
		anim = new SimpleAnimation(new Pos(169, 135));
		anim.setDuration(800);
		anim.setFrameCount(4);
		anim.setFrameInterval(200);

		this.game = game;
		this.g = ((GameLogic) game).getRender().getGraphics();
	}

	@Override
	public boolean play(float dt) {
		if (!anim.hasFinished()) {

			int frameNum = anim.getCurrFrame();
			g.drawPixmap(Assets.battle_start, anim.getPos().x, anim.getPos().y, 150 * frameNum, 0, 150, 50);
			anim.step(dt);

			return false;
		}

		game.setState(BattleState.INVADER_SET_GENERAL);
		game.getCurrPlayer().setDone(false);
		return true;
	}

}
